// Search.cpp

int Search_Bin(SSTable ST, int key)
{
    // 二分查找
    int low = 1;
    int hight = ST.length;

    while(low <= high)
    {
        int mid = (low + high) / 2;
        if(key == ST.elem[mid].key)
        {
            return mid;
        }
        else if(key < ST.elem[mid.key])
        {
            high = mid - 1;
        }
        else
        {
            low = mid + 1;
        }
    }

    return 0;
}

BiTree SearchBST(BiTree T, int key)
{
    // 二叉排序树查找
    if(!T || key == T.data.key)
    {
        return T;
    }
    else if(key < T->data.key)
    {
        return SearchBST(T->lchild, key);
    }
    else
    {
        return SearchBST(T->rchild, key);
    }
}
